<?php 
include("../config.php");
$helpid  = $_GET['helpid'];
$help_id = $_GET['help_id'];
###################################################ADD HELP###################################
$title = $_POST["helptitle"];
$content = $_POST["content"];
$subclass = $_POST["subclass"];
$time = time();
if(($title!="")&($content!="")&($helpid=="")){
$sql = "INSERT INTO helps(title,content,subclass,date) VALUES('$title','$content','$subclass',$time)";
$database->setQuery($sql);
	if($database->query()){
	echo "<script>alert('successful submit the help!');location.href('help.php')</script>";
	}else {
	echo "<script>alert('fail to  submit the help!');location.href('help.php')</script>";	
	}

}
if(($title!="")&($content!="")&($helpid!="")){
$sql = "UPDATE helps SET title='$title',content='$content',subclass='$subclass',date=$time WHERE helpid=$helpid";
$database->setQuery($sql);
	if($database->query()){
	echo "<script>alert('successful update the help!');location.href('help.php')</script>";
	}else{
	echo "<script>alert('fail to  update the help!');location.href('help.php')</script>";	
	}

}

###################################################MOD HELP###################################
if(isset($helpid)){
$sql = "SELECT * FROM  helps where helpid=$helpid";
$database->setQuery($sql);
$result1=$database->loadAssocList();
$array = array(
'','Audio & Multimedia', 'Business' ,'Communications', 'Desktop', 
'Development','Education','Games & Entertainment' ,'Graphic Apps' ,
'Home & Hobby','Security & Privacy','Servers','System Utilities','Web Development');
foreach ($array as $a){
	
	if(substr($result1[0]['subclass'],0,4)==substr($a,0,4)){
		$select[]="selected";
	}else {
		$select[]="";
	}
}
}
###################################################DEL HELP###################################
if($help_id!=""){
	$sql = "delete from helps where helpid=$help_id";
	$database->setQuery($sql);
	$database->query();
	header("Location:help.php");
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0049)http://localhost/sharewareabc/sysop/customadd.php -->
<HTML><HEAD><TITLE><?php echo $sitename; ?> - Sysop: Add/Modify Help</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META content="<?php echo $sitename; ?> - Sysop: Add/Modify Help" name=description>
<META content="free to try, software, shareware, freeware, developers, vendors, download, PAD" 
name=keywords>
<META content="Andrey Aleksanyants, M.D." name=author>
<META content="easy HTools" name=copyright>
<META http-equiv=imagetoolbar content=no><LINK 
href="../<?php echo $cssfile; ?>" 
type=text/css rel=stylesheet><LINK href="../favicon.ico" rel="shortcut icon">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR>
<script language='JavaScript'>
<!--
  function winconfirm()
  {
     question = confirm('确实要删除吗?\n'+'location=jobalter.php?id='+'<? echo $id;?>');
     if(question)
     {
         return  true;
     }
     else
     {
         return  false;
     }
 }
-->
</script>
</HEAD>
<BODY>
<TABLE class=tmain cellSpacing=0 cellPadding=0 width="906" align=center>
  <TBODY>
  <TR>
    <TD class=tmain>
      <TABLE class=tlogo cellSpacing=0 cellPadding=4 width="100%" 
        align=center><TBODY>
        <TR>
          <TD align=right>
            <P><A href="index.php">Home</A></P></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD class=tmain><BR>
      <TABLE cellSpacing=0 cellPadding=1 width="100%" align=center border=0>
        <TBODY>
        <TR vAlign=top>
          <TD align="center" class=tbody>
            <H1><?php echo $sitename?> - Sysop: Add/Modify Help </H1>
            <FORM name=addhelp  action="help.php?helpid=<?php echo $helpid?>"   method=post>
            <TABLE class=tvisible cellSpacing=0 cellPadding=4 width=640 
            align=center>
              <TBODY>
              <TR>
                <TH class=tablehead colSpan=2>Add/Modify Help </TH>
              </TR>
              <TR>
                <TD class=tdark><LABEL for=progid>
                  <P><B>Help Title:<br><br>Subclass:</B></P>
                  </LABEL></TD>
                <TD><INPUT class=text maxLength=200 size=80 name=helptitle value="<?php echo $result1[0]["title"]?>">
                <select name=subclass>
                <option value="all" <?php echo $select[0]?>>---------select subclass----------</option>
                <option value="Audio & Multimedia" <?php echo $select[1]?>>Audio & Multimedia</option>
                <option value="Business" <?php echo $select[2]?>>Business</option>
                <option value="Communications" <?php echo $select[3]?>>Communications</option>
                <option value="Desktop" <?php echo $select[4]?>>Desktop</option>
                <option value="Development" <?php echo $select[5]?>>Development</option>
                <option value="Education" <?php echo $select[6]?>>Education</option>
                <option value="Games & Entertainment" <?php echo $select[7]?>>Games & Entertainment</option>
                <option value="Graphic Apps" <?php echo $select[8]?>>Graphic Apps</option>
                <option value="Home & Hobby" <?php echo $select[9]?>>Home & Hobby</option>
                <option value="Security & Privacy" <?php echo $select[10]?>>Security & Privacy</option>
                <option value="Servers" <?php echo $select[11]?>>Servers</option>
                <option value="System Utilities" <?php echo $select[12]?>>System Utilities</option>
                <option value="Web Development" <?php echo $select[13]?>>Web Development</option>
                </select>
               
                </TD>
              </TR>
              <TR>
                <TD class=tdark><LABEL for=customurl>
                  <P><B>Help Content :</B></P>
                  </LABEL></TD>
                <TD><textarea name="content" cols="60" rows="6" class="text" id="customurl" style="background-color:D7F8AB" ><?php echo $result1[0]["content"]?></textarea></TD></TR>
              <TR>
                <TD class=tdark>
                  <P><B>Submit:</B></P></TD>
              <TD><INPUT class=button type=submit value="  Submit  " name=submit></TD></TR></TBODY></TABLE></FORM><BR>
              <BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<table width="906" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="23" align="center" class="tablehead"><strong>No</strong></td>
    <td width="383" align="center" class="tablehead"><strong>Help Title </strong></td>
    <td width="111" align="center" class="tablehead"><strong>Subclass</strong></td>
    <td width="46" align="center" class="tablehead"><strong>Date</strong></td>
    <td width="23" align="center" class="tablehead"><strong>Mod</strong></td>
    <td width="28" align="center" class="tablehead"><strong>dele</strong></td>
  </tr>
<?php 
###################################################LIST HELP###################################
$sql = "SELECT * FROM  helps ORDER BY subclass,date DESC ";
$database->setQuery($sql);
$result=$database->loadAssocList();
$total = count($result);
$perpage = 20;
$pagebarnum = 10;
$url = "./help.php";
$nowindex =$_GET['page'];
if($nowindex=="")$nowindex=1;
$begin = ($nowindex-1)*$perpage;
$sql = "SELECT * FROM  helps ORDER BY subclass,date DESC limit $begin,$perpage";
$database->setQuery($sql);
$result=$database->loadAssocList();
$page = new Page($total,$perpage,$pagebarnum,$nowindex,$url);
$no=0;
foreach ($result as $row){ 
	  $no++;
	  $title	 = $row['title'];
	  $subclass	 = $row['subclass'];
	  $helpid	 = $row['helpid'];
	  $date		 = date('j-m-y',$row['date']);
	  echo "<tr>
    <td align=\"center\">$no</td>
    <td align=\"left\">$title</td>
    <td align=\"center\">$subclass</td>
    <td align=\"center\">$date</td>
    <td align=\"center\"><a href=\"help.php?helpid=$helpid\">MOD</a></td>
    <td align=\"center\"><a href=\"javascript:if(confirm('do you delete this help?'))location='help.php?help_id=$helpid'\">DEL</a></td>
  </tr>";
}
?>
  
  <tr>
    <td colspan="6" align="center"><strong><?php echo $page->show($model=2);?></strong></td>
  </tr>
</table>
</BODY></HTML>